﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using RestSharp;

namespace SisGAC
{
    public static class Utils
    {
        public static void SendMail(string para, string assunto, string corpo)
        {
            RestClient client = new RestClient();
            client.BaseUrl = "https://api.mailgun.net/v2";
            client.Authenticator =
                    new HttpBasicAuthenticator("api",
                                               "");
            
            RestRequest request = new RestRequest();
            request.AddParameter("domain",
                                 "igorklafke.mailgun.org", ParameterType.UrlSegment);
            request.Resource = "{domain}/messages";
            request.AddParameter("from", "igorklafke@mailgun.org>");
            request.AddParameter("to", para);
            request.AddParameter("subject", assunto);
            request.AddParameter("html", corpo);
            request.Method = Method.POST;
            RestResponse response = (RestResponse)client.Execute(request);
            string teste = "";
            if (response.ErrorMessage != null)
                teste = response.ErrorMessage;
        }
    }
}